/******************************************************************************
 * @File name   :      IMaintainDealerService.java
 *
 * @Author      :      ANMA
 *
 * @Date        :      Jul 15, 2015
 *
 * @Copyright Notice: 
 * Copyright (c) 2014 DMS, Inc. All  Rights Reserved.
 * This software is published under the terms of the DMS Software
 * License version 1.0, a copy of which has been included with this
 * distribution in the LICENSE.txt file.
 * 
 * ----------------------------------------------------------------------------
 * Date                         Who         Version         Comments
 * Jul 15, 2015 7:01:52 PM    ANMA      1.0            Initial Version
 *****************************************************************************/
package com.cap.bts.crmdp.dealer.masterdata.service;

import java.io.File;
import java.io.InputStream;
import java.util.List;

import com.cap.bts.crmdp.dealer.masterdata.domain.MasterDataDealerInfo;
import com.cap.bts.crmdp.dealer.masterdata.dto.DataConvertStoredProcedure;
import com.cap.bts.crmdp.dealer.masterdata.dto.DataFixPrcResultDto;
import com.cap.bts.crmdp.dealer.masterdata.dto.DealerChangeDto;
import com.cap.bts.crmdp.dealer.masterdata.dto.DealerQueryDto;
import com.cap.bts.crmdp.dealer.masterdata.dto.DealerResultsDto;
import com.cap.bts.crmdp.dealer.masterdata.dto.DmsDataFixResultDto;
import com.cap.bts.crmdp.dealer.masterdata.dto.MaintainMasterDataSubmitDto;
import com.cap.bts.crmdp.dealer.masterdata.dto.MarsDataConversionMemberDto;
import com.cap.bts.crmdp.dealer.masterdata.dto.MarsDataConversionPortfolioDto;
import com.cap.bts.crmdp.dealer.masterdata.dto.SmsSendDto;
import com.cap.bts.framework.common.exception.AppException;
import com.cap.bts.framework.common.service.IBaseService;

/**
 * 
 */
public interface IMaintainDealerService extends IBaseService {
	
    /**
     * @Date        :      2015-7-15
     * @param queryEmployeeDto DealerQueryDto 
     * @return List<DealerResultsDto> 
     */
	public List<DealerResultsDto> getMaintainDealerByDto(DealerQueryDto dto) throws AppException;

	/**
	 * @Date        :      2015-7-16
	 * @param queryEmployeeDto DealerQueryDto 
	 * @return boolean 
	 */
	public boolean saveDealer(MaintainMasterDataSubmitDto submitDto) throws AppException;
	
	/**
	 * @Date        :      2015年7月22日
	 * @param dealerNum
	 * @return
	 * @throws AppException
	 */
	public MasterDataDealerInfo getDealerByDealerNum(String dealerNum) throws AppException;

	/**
	 * 
	 * @Date        :      Nov 20, 2015
	 * @param dearlerId
	 * @return
	 * @throws AppException
	 */
	public List<MasterDataDealerInfo> getDearlerIntoByDealerIds(List<String> dearlerIds) throws AppException;
	
    /**
     * @Date        :      2015年7月22日
     * @param dealerInfo
     */
    public boolean updateDealer(MasterDataDealerInfo dealerInfo) throws AppException;
    
    /**
     * @Date        :      2015年7月24日
     * @param operationPwd
     * @return
     * @throws AppException
     */
    public boolean getDealerByOperationPwdAndDealerNum(String operationPwd,String dealerNum) throws AppException;
    
    /**
     * @return
     * @throws AppException
     */
    public File exportMemberFromDealer(String storeCode) throws AppException;
    
    /**
     * @return
     * @throws AppException
     */
    public File exportPortfolioFromDealer(String storeCode) throws AppException;
    
    public boolean downLodeMemberFile(String remoteFile, String remotePath, String localFile) throws AppException;
    
    public boolean downLodeProtfolioFile(String remoteFile, String remotePath, String localFile) throws AppException;
    
    public String upLodeMemberFile(String storeCode) throws AppException;
    
    public String upLodePortfolioFile(String storeCode) throws AppException;


    /**
   	 * 检查门店是否存在历史数据
   	 * 
   	 * @param dearNumber
   	 * @return
   	 */
   	public boolean checkExistHistoryData(String dearNumber, boolean memberFlag, boolean portfolioFlag);
   	
   	
   	/**
   	 * 将数据写入表中
   	 * 
   	 * @param memberDtoList
   	 * @param portfolioDtoList
   	 * @return
   	 */
   	public boolean insertDTData(String batchId, List<MarsDataConversionMemberDto> memberDtoList, List<MarsDataConversionPortfolioDto> portfolioDtoList);
   	
   	
   	/**
	 * 调用存储过程处理数据
	 * 
	 * @param dealerNum
	 * @param dataType PORTFOLIO or MEMBER
	 */
	public DataConvertStoredProcedure callPrcDataConversion(String dealerNum, boolean memberFlag, boolean portfolioFlag);
	
	/**
	 * @return
	 */
	public List<DealerChangeDto> getAllDealerChange(DealerChangeDto dto);
	
	/**
	 * @param dealerNum
	 */
	public boolean updateChangeTimeFromDealerChange(String dealerNum,String changeDate);
	
	/**
	 * @param dealerNum
	 * @return
	 */
	public boolean checkDealerExisted(Long dealerNum);
	
	/**
	 * @param dealerChangeDto
	 * @return
	 */
	public boolean saveDealerChanged(DealerChangeDto dealerChangeDto);
	
	public List<DmsDataFixResultDto> handleImportInBackground(final String fileName,
	        final InputStream in, final String templateFileName, final String templateName,
	        final String sheetName) throws AppException;
	
	public void saveDmsDataFixFile(List<DmsDataFixResultDto> result) throws AppException;
	
	public List<SmsSendDto> getAllMessageForSend() throws AppException;
	
	public boolean sendMessage(List<SmsSendDto> smsSendDtoList) throws AppException;
	
	public DataFixPrcResultDto prcDmsDataFix() throws AppException;
	
	public void deleteDataFix() throws AppException;
}
